#include "widget.h"

#include <QApplication>

#include <vector>
#include <list>
#include <map>
#include <set>

#include "system-helper/SystemMacro.h"
#include "system-helper/SingleApp.h"
#include "tasync/TTaskQueue.h"
#include "encrypt/rsa/RSA.h"

//#include "notification-center/NotificationCenter.h"

DECLARE_GLOBALUI();

using namespace std;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    INIT_GLOBALUI(QThread::currentThread());

    TTaskQueue::get();

    // 注册全局唯一名称
    SingleApp si("easylib");
    if (si.hasPreviousInstance()) {
        return EXIT_SUCCESS;
    }

    if (!si.start()) {
        qDebug() << si.getLastErrorString();
        return EXIT_FAILURE;
    }

    Widget w;
    w.show();

//    TRSA::test();

//    NotificationCenter::get();

    // 弹出当前主视图
    QObject::connect(&si, &SingleApp::newInstanceCreated, [&w]() {
        qDebug() << "top";
    });

    return a.exec();
}
